package cn.com.w.simple.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Stack;


/**
 * 登录 前端控制器
 */
@Controller
public class LoginController {

    @PostMapping(value = "/doLogin")
    public String doLogin(){

        System.out.println(">>>>>>>>进入LoginController.doLogin()方法");
        System.out.println(">>>>>>>>重定向到 main.html");

        return "redirect:main.html";
    }

    /**
     * spring security 要求路径为 /login 并且 为POST
     *
     * @return
     */
    @PostMapping(value = "/login")
    public String login(){

        System.out.println(">>>>>>>>进入LoginController.login()方法");
        System.out.println(">>>>>>>>重定向到 main.html");

        return "redirect:main.html";
    }

    @GetMapping(value = "/")
    public String test(){

        System.out.println(">>>>>>>>进入LoginController.test()方法");
        System.out.println(">>>>>>>>重定向到 main.html");

        return "redirect:main.html";
    }


    /**
     * 登出
     *
     * @return
     */
    @PostMapping(value = "/logout")
    public String logout(){

        System.out.println(">>>>>>>>进入LoginController.logout()方法");
        System.out.println(">>>>>>>>重定向到 main.html");

        return "redirect:logout.html";
    }

    @RequestMapping(value = "/formLogin", method = RequestMethod.POST)
    public String formLogin(){

        System.out.println(">>>>>>>>进入LoginController.formLogin()方法");
        System.out.println(">>>>>>>>重定向到 main.html");

        return "redirect:main.html";
    }



}
